import request from '@/utils/request'

// 添加
export function addCommodity(data) {
  return request({
    url: '/commodity/add',
    method: 'post',
    data: data
  })
}

// 编辑
export function editCommodity(data) {
  return request({
    url: '/commodity/edit',
    method: 'post',
    data: data
  })
}

// ID查询单个数据
export function getCommodity(id) {
  return request({
    url: '/commodity/info',
    method: 'post',
    params: { id }
  })
}

// 删除
export function delCommodity(id) {
  return request({
    url: '/commodity/delete',
    method: 'post',
    params: { id }
  })
}

// 批量删除
export function delListCommodity(idList) {
  return request({
    url: '/commodity/delete/list',
    method: 'post',
    data: idList
  })
}

// 查询分页数据
export function dataCommodity(query) {
  return request({
    url: '/commodity/data',
    method: 'post',
    params: query
  })
}

// 查询全部数据
export function allCommodity() {
  return request({
    url: '/commodity/all',
    method: 'post',
  })
}

// 条件查询列表数据
export function listCommodity(data) {
  return request({
    url: '/commodity/list',
    method: 'post',
    data: data
  })
}

// 根据字段、排序方式、limit条 查询列表数据
export function listLimitCommodity(field, sort, limit) {
  return request({
    url: '/commodity/list/limit',
    method: 'post',
    params: { field, sort, limit }
  })
}

// 根据字段查询列表数据
export function listFieldCommodity(field, value) {
  return request({
    url: '/commodity/list/field',
    method: 'post',
    params: { field, value }
  })
}

// 动态查询单个数据
export function dynamicGetCommodity(data) {
  return request({
    url: '/commodity/info/dynamic',
    method: 'post',
    data: data
  })
}

// 查看详情数据
export function detailsGetCommodity(id) {
  return request({
    url: '/commodity/details',
    method: 'post',
    params: { id }
  })
}

// 全部条数
export function countCommodity() {
  return request({
    url: '/commodity/count',
    method: 'post',
  })
}

// 条件查询条数
export function dynamicCountCommodity(data) {
  return request({
    url: '/commodity/count/dynamic',
    method: 'post',
    data: data
  })
}

export function statisticsCommodityCategory() {
  return request({
    url: '/commodity/statistics/category',
    method: 'post',
  })
}
